package com.starview.platform.data.type;

/**
 * A transformer interface for type expressions and constraints
 * 
 * @author fgm
 * 
 */
public interface TypeTransformer<T, C>
{
  T transformSimpleType(Type t);

  /**
   * Apply the transformer to a type expression. This includes most concrete types, including
   * function types, record types, tuple types, etc.
   * 
   * @param t
   */
  T transformTypeExp(TypeExp t);

  /**
   * Apply the transformer to an interface type;
   * 
   * @param t
   */
  T transformTypeInterface(TypeInterfaceType t);

  /**
   * Apply the transformer to a type variable. Note that it is guaranteed that the type variable is
   * not bound to a concrete type; but it may have type constraints applied to it.
   * 
   * @param v
   */
  T transformTypeVar(TypeVar v);

  /**
   * Apply the transformer to an existentially quantified type.
   * 
   * @param t
   */
  T transformExistentialType(ExistentialType t);

  /**
   * Apply the transformer to a universally quantified type.
   * 
   * @param t
   */
  T transformUniversalType(UniversalType t);

  /**
   * Constraints are also part of types
   * 
   * @param con
   * @return
   */

  /**
   * Transform a contract constraint
   * 
   * @param con
   * @return
   */
  C transformContractConstraint(ContractConstraint con);

  /**
   * transform a has kind constraint
   * 
   * @param has
   * @return
   */
  C transformHasKindConstraint(HasKind has);

  /**
   * transform an instance of constraint
   * 
   * @param inst
   * @return
   */
  C transformInstanceOf(InstanceOf inst);

  /**
   * Transform a field constraint
   * 
   * @param fc
   * @return
   */
  C transformFieldConstraint(FieldConstraint fc);

  /**
   * transform a type field constraint
   * 
   * @param tc
   * @return
   */
  C transformFieldTypeConstraint(FieldTypeConstraint tc);

  /**
   * transform a tuple constraint
   * 
   * @param t
   * @return
   */
  C transformTupleContraint(TupleConstraint t);
}
